// import React from 'react'
import cookie from 'react-cookies'
import { Navigate } from 'react-router-dom'

const AuthRouter = (props) => {
    //说明判断是否要登录
    if (props.auth) {
        // 获取cookies的LoginUser
        var LoginUser = cookie.load('LoginUser') ? cookie.load('LoginUser') : {}

        if (JSON.stringify(LoginUser) === "{}") {
            return (
                <Navigate to="/user/base/login" />
                // <React.$router.Navigate to="/user/base/login" />
            )
        } else {
            return (
                <>
                    {props.component}
                </>
            )
        }
    } else {
        return (
            <>
                {props.component}
            </>
        )
    }
}

export default AuthRouter